home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / WINDOWS / WBB11.ARJ / SAMPLEB3.BAS < prev    next >
BASIC Source File  |  1992-05-08  |  5KB  |  272 lines

  1.  
  2.  
  3. rem
  4. rem Dumb terminal program
  5. rem
  6. rem This is a fairly complete example of using buttons in DOS and Windows
  7. rem
  8.  
  9.  
  10.   rem
  11.   rem is there mouse
  12.   rem
  13.   mouseflag=mouseon
  14.  
  15.  
  16.   rem
  17.   REM
  18.   REM LAYOUT SCREEN
  19.   REM
  20.   CLS
  21.  
  22.   rem
  23.   rem make red bar at top
  24.   rem
  25.   color 7,4
  26.   locate 1,1
  27.   print space$(80);
  28.   locate 2,1
  29.   print space$(80);
  30.   locate 3,1
  31.   print space$(80);
  32.  
  33.   if mouseflag<>0 then
  34.  
  35.     rem
  36.     rem make my push buttons
  37.     rem
  38.     CBUTTON "Exit",1068,0,"Push",0,1,1,8,3,7,1
  39.     CBUTTON "Hangup",1059,0,"Push",0,71,1,10,3,7,1
  40.  
  41.     rem
  42.     rem make and turn on correct radio buttons
  43.     rem
  44.     cbutton " Full Duplex",1060,0,"Radio",0,12,1,13,1,7,4
  45.     cbutton " Half Duplex",1061,0,"Radio",0,12,2,13,1,7,4
  46.     Radioon 1061
  47.     cbutton " 8 data bits",1062,0,"Radio",0,27,1,13,1,7,4
  48.     cbutton " 7 data bits",1063,0,"Radio",0,27,2,13,1,7,4
  49.     Radioon 1062
  50.     cbutton " 2400 baud",1064,0,"Radio",0,42,1,12,1,7,4
  51.     cbutton " 1200 baud",1065,0,"Radio",0,42,2,12,1,7,4
  52.     cbutton " 300 baud",1066,0,"Radio",0,42,3,12,1,7,4
  53.     Radioon 1065
  54.  
  55.   else
  56.  
  57.     rem
  58.     rem make my push buttons
  59.     rem
  60.     CBUTTON "F10-Exit",1068,0,"Push",0,1,1,10,3,7,4
  61.     CBUTTON "F1-Hangup",1059,0,"Push",0,68,1,13,3,7,4
  62.  
  63.     rem
  64.     rem make and turn on correct radio buttons
  65.     rem
  66.     cbutton " F2-Full",1060,0,"Radio",0,12,1,13,1,7,4
  67.     cbutton " F3-Half",1061,0,"Radio",0,12,3,13,1,7,4
  68.     Radioon 1061
  69.     cbutton " F4-8 data",1062,0,"Radio",0,27,1,13,1,7,4
  70.     cbutton " F5-7 data",1063,0,"Radio",0,27,2,13,1,7,4
  71.     Radioon 1062
  72.     cbutton " F6-2400",1064,0,"Radio",0,42,1,12,1,7,4
  73.     cbutton " F7-1200",1065,0,"Radio",0,42,2,12,1,7,4
  74.     cbutton " F8-300",1066,0,"Radio",0,42,3,12,1,7,4
  75.     Radioon 1065
  76.   end if
  77.  
  78.   rem
  79.   rem default states
  80.   rem
  81.   fullhalf=1061
  82.   bits$="8,"
  83.   parity$="N,"
  84.   speed$="1200,"
  85.   stop$="1,"
  86.  
  87.   rem
  88.   rem define scrollable area (so it doesn't scroll buttons)
  89.   rem
  90.   scrollarea 1,4,80,25
  91.   color 7,0
  92.   locate 4,1
  93.  
  94.  
  95.   rem
  96.   rem open communications port
  97.   rem
  98. '  if bits$="8" then
  99. '    OPEN "com1: 2400,N,8" FOR RANDOM AS #1 LEN=2048
  100. '  else
  101. '    open "com1: 2400,E,7" for random as #1 len=2048
  102. '  end if
  103.    open "com2:"+speed$+parity$+bits$+stop$ for random as #1 len=2048
  104.  
  105.    rem
  106.    rem misc.
  107.    rem
  108.    lf$=chr$(10)
  109.  
  110. 100
  111.  
  112. rem
  113. rem get input from communications port
  114. rem
  115. rem
  116. rem Strip out LF characters
  117. rem
  118.  
  119.   t = LOC(1)
  120.   IF t > 0 THEN
  121.     a$=input$(t,1)
  122.     if len(a$)>0 then
  123. nocr:
  124.       if lastchar$=chr$(13)
  125.         l=len(a$)
  126.         t=instr(a$,lf$)
  127.         if t>0 then
  128.          if l>1 then
  129.           a$=left$(a$,t-1)+right$(a$,l-t)
  130.           goto nocr
  131.          else
  132.           goto 100
  133.          end if
  134.         end if
  135.      end if
  136.      PRINT a$;
  137.      lastchar$=a$
  138.     ELSE
  139.  
  140.       rem come here if some kind of comm error
  141.     end if
  142.  
  143.  
  144.   END IF
  145.  
  146.  
  147.  
  148. rem
  149. rem get input from keyboard
  150. rem
  151.  
  152.   b$ = INKEY$
  153.  
  154.  
  155.   IF b$ <> "" THEN
  156.  
  157.     rem
  158.     rem look for function keys
  159.     rem
  160.  
  161.     if len(b$)>1 then
  162.  
  163.       if asc(right$(b$,1))=68 then
  164.  
  165.     rem
  166.     rem F10 exit
  167.     rem
  168.     close #1
  169.     stop
  170.  
  171.       elseif asc(right$(b$,1))=59 then
  172.  
  173.     rem
  174.     rem F1- Hangup
  175.     rem
  176.     beep             :rem positive sign button was pushed
  177.     print #1,"+++";
  178.     for t=0 to 4000
  179.     next t
  180.     print #1,"ATH";chr$(13);
  181.  
  182.       elseif asc(right$(b$,1))=60 then
  183.     rem
  184.     rem make full duplex
  185.     rem
  186.     fullhalf=0
  187.     Radiooff 1061
  188.     Radioon 1060
  189.  
  190.       elseif asc(right$(b$,1))=61 then
  191.     rem
  192.     rem make half duplex
  193.     rem
  194.     fullhalf=1
  195.     Radiooff 1060
  196.     Radioon 1061
  197.  
  198.       elseif asc(right$(b$,1))=62 then
  199.     rem
  200.     rem make 8 data bits
  201.     rem
  202.     bits$="8,"
  203.     parity$="N,"
  204.     stop$="1,"
  205.     Radiooff 1063
  206.     Radioon 1062
  207.     setcom 1,","+parity$+bits$+stop$
  208.  
  209.       elseif asc(right$(b$,1))=63 then
  210.     rem
  211.     rem make 7 data bits
  212.     rem
  213.     bits$="7,"
  214.     Parity$="E,"
  215.     stop$="1,"
  216.     Radiooff 1062
  217.     Radioon 1063
  218.     setcom 1,","+parity$+bits$+stop$
  219.  
  220.       elseif asc(right$(b$,1))=64 then
  221.     rem
  222.     rem make 2400 baud
  223.     rem
  224.     speed$="2400,"
  225.     Radiooff 1065
  226.     Radiooff 1066
  227.     Radioon 1064
  228.     setcom 1,speed$
  229.  
  230.       elseif asc(right$(b$,1))=65 then
  231.     rem
  232.     rem make 1200 baud
  233.     rem
  234.     speed$="1200,"
  235.     Radiooff 1064
  236.     Radiooff 1066
  237.     Radioon 1065
  238.     setcom 1,speed$
  239.  
  240.       elseif asc(right$(b$,1))=66 then
  241.     rem
  242.     rem make 300 baud
  243.     rem
  244.     speed$="300,"
  245.     Radiooff 1064
  246.     Radiooff 1065
  247.     Radioon 1066
  248.     setcom 1,speed$
  249.  
  250.  
  251.       end if
  252.  
  253.       goto 100
  254.  
  255.     else
  256.  
  257.       if fullhalf=0 then
  258.     print b$;
  259.       end if
  260.       PRINT #1, b$;
  261.  
  262.     end if
  263.  
  264.   END IF
  265.  
  266.   GOTO 100
  267.  
  268.  
  269.  
  270.  
  271.  
  272.